#include <stdio.h>

int search(int nums[], int target, int left, int right) {
	int mid = (left + right) / 2;
	int flag = 0;
	int index = 0;


	while (left <= right) {
		if (nums[mid] == target) {
			flag = 1;
			index = mid;
			break;
		} else if (target < nums[mid]) {
			right = mid - 1;
			mid = (left + right) / 2;
		} else {
			left = mid + 1;
			mid = (left + right) / 2;
		}

	}


	if (1 == flag) {
		return index;
	} else {
		return -1;
	}
}



int main() {
	int n = 0;
	int m = 0;
	int nums[50000] = { 0 };
	int targets[50000] = { 0 };
	int i = 0;
	int j = 0;
	int ret = 0;
	int left = 0;
	int right = 0;
	scanf("%d %d", &n, &m);
	right = n - 1;
	for (i = 0; i < n; i++) {
		scanf("%d", &nums[i]);
	}
	for (i = 0; i < m; i++) {
		scanf("%d", &targets[i]);
	}

	for (i = 0; i < m; i++) {
		ret = search(nums, targets[i], left, right);
		printf("%d\n", ret);
	}


	return 0;
}
